<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href='<?php echo base_url()?>'>
<link rel="stylesheet" type="text/css" href="public/common/css/common.css"/>
<link rel="stylesheet" type="text/css" href="public/admin/css/admin.css"/>
<script src="public/common/js/jquery.js"></script>
<script>
$(function(){
	$('.table tr').hover(function(){
		$(this).children('td').css('background','#ccffcc');
	},function(){
		$(this).children('td').css('background','white');
	});
});

function select_all()
{
	$('.table').find('input:checkbox').attr('checked',true);
}
function select_other()
{
	check_obj = $('.table').find('input:checked');
	$('.table').find('input:checkbox').attr('checked',true);
	check_obj.attr('checked',false);
}
function delete_select_content()
{
	if(confirm('确定删除所选吗？删除后不可恢复！'))
	{
		$('input:checked').each(function(){
			del(this,$(this).val());
		});
	}
}
function delete_content(obj,msg_id)
{
	if(confirm('确定要删除吗？删除后不可恢复！'))
	{
		del(obj,msg_id);
	}
}
function del(obj,msg_id)
{
	$.post('<?php echo site_url("admin/msg/delete_content")?>',{msg_id:msg_id},function(result){
			if(result == '1')
			{
				$(obj).parent().parent().remove();
			}else{
				alert('删除失败！');		
			}
	});
}

function shenhe_select()
{
	$('input:checked').each(function(){
		obj = this;
		$.post('<?php echo site_url("admin/msg/shenhe_msg")?>',{msg_id:$(this).val()});	
	});
	alert('审核通过');
	location.reload();
}
</script>
</head>
<body>
	<div class="body">
    	<?php echo $this->position->get_position();?>
        <div class="body_center">
        	<table class="table" style="margin-bottom:0px;">
            	<tr><th>选择</th><th>留言标题</th><th>留言内容</th><th>留言用户</th><th>留言状态</th><th>审核</th><th>留言时间</th><th>操作</th></tr>
                 <?php if(empty($msg)):?>
                 <tr><td colspan="7" align="center">没有任何数据！</td></tr>
                 <?php else:?>
                 <?php foreach($msg->result() as $value):?>
                   <tr>
					   <td align="center"><input type="checkbox" value="<?php echo $value->msg_id?>"></td>
                       <td align=center><?php echo substr($value->msg_title,0,20)?></td>
					   <td align=center><?php echo substr($value->msg_content,0,20)?></td>
					   <td align=center><?php echo $value->msg_user?></td>
					   <td align=center><?php if($value->msg_status == '1'):?><font color='green'>未回复</font><?php elseif($value->msg_status == '2'):?>已回复<?php else:?><font color='red'>未读</font><?php endif;?></td>
					   <td align=center><?php if($value->msg_shenhe == '1'):?>已审核<?php else:?><font color='red'>未审核</font><?php endif?></td>
					   <td align=center><?php echo date('Y-m-d',$value->msg_create_time)?></td>
                       <td align="center"><a href="<?php echo site_url('admin/msg/msg_reply/'.$value->msg_id)?>"><?php if($value->msg_status == '2' or $value->msg_status == '0'):?>查看<?php else:?>回复<?php endif?></a> | <a href="javascript:void(0)" onclick="delete_content(this,<?php echo $value->msg_id?>)">删除</a></td>
                   </tr>
                   <?php endforeach;?>
                 <?php endif;?>  	
                <tr>
               		<td colspan="8" align="right">
                    	<input type=button class="submit" value="全选" onclick="select_all()"> 
                        <input type=button onclick="select_other()" class="submit" value="反选"> 
						<input type=button value="已审核" class="submit" onclick="shenhe_select()">
                        <input type=button value="删除" class="submit" onclick="delete_select_content()">
                     </td>
                </tr>
            </table>
        </div>
        <div class="page"><?php echo $page?></div>
    </div>
</body>
</html>